#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
#define fi first
#define se second
#define db double
using namespace std;
const int N = 1e6+5;
int T,n,m,L,vmax;//
vector<db> va[N];//
int vb[N];//
bool vis[N];
bool op[N];
int quan=0,maxn=0;
void ssolve()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            db d=va[i][0],v = va[i][1],a = va[i][2];
            if(d>vb[j]||op[j]==0) continue;
            db dis = vb[j]-d;
            db v1f = v*v+2*a*dis;
            db x = abs(v*v/(2*a));
            if(x<=dis)
            {
                continue;
            }
            if(v1f<=0) continue;
            if(v1f>vmax*vmax&&vis[i]==0)
            {
                quan++;
                vis[i] = 1;
            }
        }
    }
}
void solve1(int cnt)
{
    int ans = 0;
    for(int i=1;i<=n;i++) vis[i] = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            db d=va[i][0],v = va[i][1],a = va[i][2];
            if(d>vb[j]||op[j]==0) continue;
            db dis = vb[j]-d;
            db v1f = v*v+2*a*dis;
            db x = abs(v*v/(2*a));
            if(x<=dis)
            {
                continue;
            }
            if(v1f<=0) continue;
            if(v1f>vmax*vmax&&vis[i]==0)
            {
                ans++;
                vis[i] = 1;
            }
        }
    }
    //cout<<ans<<" ";
    if(ans==quan) maxn = max(maxn,cnt);
}
void solve2(int cnt)
{
    for(int i=1;i<=n;i++) vis[i] = 0;
    int ans =0 ;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            db d=va[i][0],v = va[i][1],a = va[i][2];
            if(d>vb[j]||op[j]==0) continue;
            db dis = vb[j]-d;
            db v1f = v*v+2*a*dis;
            db x = abs(v*v/(2*a));
            if(x<=dis)
            {
                continue;
            }
            if(v1f>vmax*vmax&&vis[i]==0)
            {
                ans++;
                vis[i] = 1;
            }
        }
    }
    //for(int i=1;i<=n;i++) cout<<vis[i]<<" ";
    //cout<<"\n";
    if(ans==quan) maxn = max(maxn,cnt);
}
void dfs(int now,bool st,int sum)
{
    op[now] = st;
    if(now==n)
    {
        solve1(sum);
        return;
    }
    dfs(now+1,1,sum);
    dfs(now+1,0,sum+1);
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    IOS;
    cin>>T;
    while(T--)
    {
        quan = 0;
        maxn = 0;
        for(int i=1;i<=n;i++)
        {
            vis[i] = 0;
            va[i].clear();//ka le wo 1h fu le
        }
        cin>>n>>m>>L>>vmax;
        for(int i=1;i<=n;i++)
        {
            int d,v,a;
            cin>>d>>v>>a;
            va[i].push_back(d);
            va[i].push_back(v);
            va[i].push_back(a);
        }
        for(int i=1;i<=m;i++)
        {
            cin>>vb[i];
            op[i] = 1;
        }
        ssolve();//quankai
        dfs(0,0,0);
        cout<<quan<<" "<<maxn<<"\n";
    }
}
